#pragma once
#include "XPngButton.h"

#define DEFAULT_BUTTON_COUNT	10
#define ID_CUSTOM_CLOSE_BUTTON	65535


class CXTitlebar : public CWindowImpl<CXTitlebar>
{
public:
	CXTitlebar(void);
	~CXTitlebar(void);

	BEGIN_MSG_MAP_EX(CXTitlebar)
		MSG_WM_PAINT(OnPaint)
		MSG_WM_ERASEBKGND(OnEraseBkgnd)
		MSG_WM_COMMAND(OnCommand)
	END_MSG_MAP()

	LRESULT OnCommand(UINT , int nMsg, HWND hWnd)
	{
		::PostMessage(GetParent().m_hWnd, WM_COMMAND, nMsg, 0);
		return DefWindowProc();
	}

	LRESULT OnPaint(HDC);
	LRESULT OnEraseBkgnd(HDC);

	void AddButton(UINT nID, const CString & strPng, int nButtonState, int nRightOffset = 0, CString strText = "", CString strTooltipText = "");
	void SetTitleText(const CString & str, COLORREF color){m_strTitle = str;m_colorTitle = color;};
	void SetIconPng(const CString & strPng);
private:
	CXPngButton *	m_pButtons[DEFAULT_BUTTON_COUNT];
	CRect 			m_RectOffset;
	CString			m_strTitle;
	COLORREF		m_colorTitle;
	IXpng		*	m_pIconPng;
};
